<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSellTable extends Migration
{
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
    Schema::create('sell', function (Blueprint $table) {
      $table->string('id')->primary();
      $table->foreignId('member_id');
      $table->foreignId('seller_id')->nullable();
      $table->foreignId('agent_id')->nullable();
      $table->string('bank')->comment('银行');
      $table->string('bankcard')->comment('银行卡号');
      $table->string('realname')->comment('姓名');
      $table->unsignedDecimal('coins', 16, 3);
      $table->unsignedDecimal('fee', 10, 3)->default(0)->comment('手续费');
      $table->unsignedDecimal('tip', 10, 3)->default(0)->comment('单笔奖励');
      $table->enum('state', ['pending', 'pass', 'reject', 'done', 'canceled', 'locking', 'checking'])->default('pending');
      // $table->timestamp('took_at')->nullable();
      $table->timestamp('done_at')->nullable();
      $table->timestamps();
    });
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
    Schema::dropIfExists('sell');
  }
}
